<script>
	import api from 'common/apiUrl.js'
	import Vue from 'vue';
	export default {
		// 此处globalData为了演示其作用，不是uView框架的一部分
		globalData: {
			username: '白居易',
			AMapWX: '9d295234a7c11fa1890621613af093ed',
			title: '半价商城',
			summary: '快来加入半价商城，给您提供更好的服务'
		},
		methods: {},
		onLoad() {
	
		},
		onHide() {
			if (uni.getStorageSync('noOnHide')) {
				return
			}
			console.log('清空onHide')
			uni.removeStorageSync('regcode')
			uni.setClipboardData({
				data: '',
				showToast: false,
				success: () => {
					uni.hideToast();
				}
			})
		},
		onUnload() {
			if (uni.getStorageSync('noOnHide')) {
				return
			}
			console.log('清空onUnload')
			uni.removeStorageSync('regcode')
			uni.setClipboardData({
				data: '',
				showToast: false,
				success: () => {
					uni.hideToast();
				}
			})
		},
		onShow() {
			if (uni.getStorageSync('token')) {
				this.$api.get_my_massage({},(res)=>{
					uni.setStorageSync("userinfo",res.data.data.data)
				})
			}
			uni.removeStorageSync('noOnHide')
			// #ifdef APP-PLUS || MP-WEIXIN || H5
			uni.getClipboardData({
				success: (res) => {
					console.log('剪切板内容', res)
					uni.hideToast();
					if (res.data != '') {
						if (res.data.indexOf('商品编号') > 0) {
							uni.setStorageSync('regcode', res.data.split('&')[1])
							let section = res.data.split('&')
							if (res.data.split('复制信息')[0] == 'integral') {
								uni.navigateTo({
									url: `/pages/home/shopmassage?num=${res.data.split('#')[1]}`
								})
							} else {
								uni.navigateTo({
									url: `/pages/home/paymassage?num=${res.data.split('#')[1]}`
								})
							}
							uni.setClipboardData({
								data: '',
								showToast: false,
								success: () => {
									uni.hideToast();
								}
							})
						} else {
							if (res.data) {
								uni.setStorageSync('regcode', res.data)
							}
							uni.setClipboardData({
								data: '',
								showToast: false,
								success: () => {
									uni.hideToast();
								}
							})
						}
					}
				}
			});
			// #endif
		},
		onLaunch: async function(options) {
			// #ifdef APP-PLUS
			this.$update.checkUpdate()
			// #endif

		},
	}
</script>
<style lang="scss">
	@import "uview-ui/index.scss";

	page {
		width: 100%;
		height: 100%;
		font-size: 30rpx;
		color: #333333;
	}

	.serDrop {
		.u-dropdown__menu__item__text {
			color: #FFFFFF !important;
		}

		.u-icon__icon {
			color: #FFFFFF !important;
		}
	}

	::v-deep(.u-form-item__message) {
		padding-left: 0 !important;
	}
</style>